<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<html>
  <head>
      <title>MedLine search results data - Bitzer</title>
      <!--<link rel="StyleSheet" href="assets/css/style.css" type="text/css" />-->

  </head>
  <body>

      <?php
            
            include("../includes/custom/bal_medline.php");
            
            $bal = new BAL();

            $keyword = $bal->getSearchKeyword($_SERVER['QUERY_STRING']);

            $search_results = $bal->getSearchResults($keyword);

            //$all_current_parts_items = $bal->getCountAtCurrentLevel();

      ?>

       <table data-bitzer-data="true"
              data-bitzer-title="Search Results"
              data-bitzer-desc="Medline search results"
              data-bitzer-component="search"
              data-bitzer-record-count="<?php echo count($search_results); ?>"
              <?php
                if(!isset ($bal->params["recordCount"]) || $bal->params["recordCount"][0] == "N")
                {
              ?>
              data-bitzer-number-of-rows="<?php echo count($search_results); ?>"
              data-bitzer-start-index="<?php if(isset ($bal->params['startRow'])) { echo $bal->params['startRow'][0]; } else { echo "0"; } ?>"
              <?php
                }
              ?>
              width="100%">

           <?php
                if(isset ($bal->params["recordCount"]) && $bal->params["recordCount"][0] == "Y")
                {
           ?>
                    <tr>
                        <td>Record Count</td>
                        <td><?php echo count($search_results); ?></td>
                    </tr>

           <?php
                }
                else
                {
           ?>

         <tr>
             <?php
                $first_result = $search_results[0];

                if(!is_null($first_result))
                {
                foreach($first_result as $header => $value)
                {
                    if(!is_numeric($header))
                    {
                        if($header == "id")
                        {
             ?>
                            <th data-bitzer-field="id" data-bitzer-key-order="1">ID</th>
             <?php
                        }
                        else if($header == "title")
                        {
             ?>
                            <th data-bitzer-field="title">Title</th>
             <?php
                        }
                        else if($header == "organization")
                        {
             ?>
                            <th data-bitzer-field="organization">Organization</th>
             <?php
                        }
                        else if($header == "snippet")
                        {
             ?>
                            <th data-bitzer-field="snippet">Snippet</th>
             <?php
                        }
                        else if($header == "url")
                        {
             ?>
                            <th data-bitzer-field="url">URL</th>
             <?php
                        }
             
                        }
                    }
                    }
                }
             ?>
                            <th data-bitzer-field="lastModifiedOn">Last Modified On</th>
         </tr>

         <?php
            if(is_array($search_results))
            {
                foreach($search_results as $result)
                {
                    
         ?>

                    <tr data-bitzer-pk-name="id"
                        data-bitzer-pk-value="<?php echo $result->id; ?>">

                        <?php
                            foreach($result as $property => $value)
                            {
                                if(!is_numeric($property))
                                {
                        ?>
                                <td><?php
                                        echo trim($value);
                                    ?></td>
                        <?php
                                }
                            }
                        ?><td>2011-03-14 12:50:00 PST</td></tr>
         <?php
                }
            }
                
         ?>
       </table>
  </body>
</html>